package com.yusys.jin.blog.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;


public class UrlChangeFilter implements Filter {


    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.err.println("过滤器创建了");
        Filter.super.init(filterConfig);
    }

    @Override
    public void destroy() {
        // TODO Auto-generated method stub
        Filter.super.destroy();
    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            throws IOException, ServletException {
        System.err.println("过滤器执行任务");
        HttpServletRequest request1 = (HttpServletRequest) request;
        String url = request1.getRequestURI();
        System.err.println(url);
        request.getRequestDispatcher("/blog-0.0.1-SNAPSHOT" + url).forward(request, response);
        chain.doFilter(request, response);
    }


}
